// 公共基础接口

import request from '@/utils/request'
import { ISmsparams, ISaveparams, Iloginparams, IloginResponse } from './types/common'

// interface ResponseData<T = any> {
//   status: number
//   mag: string
//   data: T
// }

// 注册保存 -- 手机号方式
export const getSave = (params: ISaveparams) => {
  return request<ISaveparams>({
    method: 'POST',
    url: '/register/save',
    params
  })
}

// 手机短信获取验证码
export const getSmsCode = (params: ISmsparams) => {
  return request<ISmsparams>({
    method: 'POST',
    url: '/register/smscode',
    params
  })
}

// 获取图形验证码
export const getCaptcha = () => {
  return request<Blob>({
    method: 'GET',
    url: '/code',
    params: {
      k: '0.197628373947345873'
    },
    responseType: 'blob'
  })
}

// 登录成功  -- 手机号方式
export const login = (params: Iloginparams) => {
  return request<IloginResponse>({
    method: 'POST',
    url: '/login/mobile/v2',
    params
  })
}

// 校验tokne 时效性
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/user/info'
  })
}

export const getChechToken = () => {
  return request({
    method: 'GET',
    url: '/user/checkToken'
  })
}

// 退出登录
export const logout = () => {
  return request({
    method: 'GET',
    url: '/login/exit'
  })
}
